﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using System.Threading;
using System.Net;
using Mighty.Common;
using System.Xml.Serialization;
using System.IO;
using PlayingBoard.on;

namespace Mighty.PlayingBoard
{
    public class Network
    {
        delegate void add_msg();

        List<OnlinePlayer> clients = new List<OnlinePlayer>();

        public void SendData(byte[] data, Socket client)
        {
            try
            {
                int total = 0;
                int size = data.Length;
                int left_data = size;
                int send_data = 0;

                // 전송할 실제 데이터의 크기 전달
                byte[] data_size = new byte[4];
                data_size = BitConverter.GetBytes(size);
                send_data = client.Send(data_size);

                // 실제 데이터 전송
                while (total < size)
                {
                    send_data = client.Send(data, total, left_data, SocketFlags.None);
                    total += send_data;
                    left_data -= send_data;
                }
            }
            catch (Exception)
            {
                //p.DebugMsgAdd(ex.Message);
            }
        }


    }
}
